package org.cocos2d.particlesystem;

import org.cocos2d.nodes.CCDirector;
import org.cocos2d.nodes.CCTextureCache;
import org.cocos2d.types.CGPoint;
import org.cocos2d.types.CGSize;
import org.cocos2d.types.ccBlendFunc;
import org.cocos2d.types.ccColor4F;

public class CCParticleStar extends CCQuadParticleSystem {

    public static CCParticleStar node() {
        return new CCParticleStar();
    }
    
    public static CCParticleStar node(int p) {
        return new CCParticleStar(p);
    }

    protected CCParticleStar() {
        this(50);
    }

    protected CCParticleStar(int p) {
        super(p);

		// duration
		duration = kCCParticleDurationInfinity;

		// Gravity Mode
		emitterMode = kCCParticleModeGravity;

		// Gravity Mode: gravity
		this.setGravity(CGPoint.ccp(0,0));
		
		// Gravity Mode: speed of particles
		setSpeed( 160 );
		setSpeedVar( 20 );
		
		// Gravity Mode: radial
		setRadialAccel( -60 );
		setRadialAccelVar( 0 );
		
		// Gravity Mode: tagential
		setTangentialAccel( 30 );
		setTangentialAccelVar( 0 );

		// angle
		angle = 90;
		angleVar = 360;
		
		// emitter position
		CGSize winSize = CCDirector.sharedDirector().winSize();
		this.setPosition(CGPoint.ccp(winSize.width/2, winSize.height/2));
		posVar = CGPoint.zero();
		
		// life of particles
		life = 4;
		lifeVar = 1;
		
		// spin of particles
		setStartSpin(0);
		setStartSpinVar(0);
		setEndSpin(0);
		setEndSpinVar(2000);
		
		// size, in pixels
		startSize = 80.0f;
		startSizeVar = 30.0f;
		endSize = 0;

		// emits per second
		emissionRate = totalParticles/life;
		
		// color of particles
		ccColor4F startColor = new ccColor4F(0.8f, 0.3f, 0.2f, 1.0f);
		setStartColor(startColor);
		ccColor4F startColorVar = new ccColor4F(0.2f, 0.2f, 0.2f, 1.0f);
		setStartColorVar(startColorVar);
		ccColor4F endColor = new ccColor4F(0.1f, 0.1f, 0.1f, 0.2f);
		setEndColor(endColor);
		ccColor4F endColorVar = new ccColor4F(0.1f, 0.1f, 0.1f, 0.2f);	
		setEndColorVar(endColorVar);
		
		setTexture(CCTextureCache.sharedTextureCache().addImage("fire.png"));

        // additive
//		setBlendAdditive(true);
    }

	@Override
	public ccBlendFunc getBlendFunc() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void setBlendFunc(ccBlendFunc blendFunc) {
		// TODO Auto-generated method stub
		
	}

}

